package utils.others 
{
	/**
	 * ...
	 * @author WLDragon 2013-11-22
	 */
	public class Utils 
	{
		/**
		 * 求按某单位将a的值减给b时的实际可减数
		 * @param	$a
		 * @param	$b
		 * @param	$bMax b值的最大容量
		 * @param	$unit 一单位
		 * @return	可减的数
		 */
		public function passAToB($a:int, $b:int, $bMax:int = 9999, $unit:int = 100):int
		{
			var s:int;
			var r:int;
			if ($a > $unit)
			{
				s = $b + $unit;
				if (s > $bMax)
					r = $bMax - $b;
				else
					r = $unit;
			}
			else
			{
				s = $b + $a;
				if (s > $bMax)
					r = $bMax - $b;
				else
					r = $a;
			}
			
			return r;
		}
		
		public function radomArray(target:Array):void
		{
			var r:int;
			var tmp:*;
			var len:int = target.length;
			for (var i:int = 0; i < len; i++)
			{
				r = Math.random()*len;
				tmp = target[i];
				target[i] = target[r];
				target[r] = tmp;
			}
		}
	}

}